package com.example.common;


import org.springframework.util.DigestUtils;

import java.io.UnsupportedEncodingException;

public class StringTools {
    public static final String ENCODING = "utf-8" ;
    private static final String SALT = "salt" ;

    public static String md5(String str) {
        // md5 加密
        try {
            return DigestUtils.md5DigestAsHex(
                    (str + SALT).getBytes(ENCODING)
            ) ;
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }

    }


}
